<template>
  <div class="grid-item-box" :class="!isTop ? 'bg-box' : ''">
    <div class="flex justify-center align-center">
      <img v-if="imgPath" :src="imgPath" />
      <div class="title padding-left-5">
        <span>{{ title }}</span>
        <span v-if="isTop" v-tooltip="title" class="icon el-icon-question padding-left-5"></span>
      </div>
    </div>
    <div class="total-price">{{ model.totalPrice | moneyFilterNoUnit }}<span class="font-size-14">万元</span></div>
    <div class="plan-item">
      <span class="first" :class="isAll ? 'plan-box-l' : 'plan-box-m'">{{ isAll ? '年度计划总额' : '年度计划' }}：</span>
      <span>{{ model.totalYearPlantPrice | moneyFilterNoUnit }}</span>
      <span class="difference-box">达成率：</span>
        <span v-if="normType == 1 || normType == 3">{{ Math.abs(model.completionRate || 0) | accMul }}%</span>
        <span v-if="normType == 2 || normType == 4">{{ Math.abs(model.completionRate || 0) | accMul }}%</span>
    </div>
    <div class="plan-item margin-top-5">
      <span class="first" :class="isAll ? 'plan-box-l' : 'plan-box-m'">{{ isAll ? '累计计划' : '累计计划' }}：</span>
      <span>{{ model.totalPlantPrice | moneyFilterNoUnit }}</span>
      <span class="difference-box">差异率：</span>
        <span v-if="normType == 1 || normType == 3" :class="model.differenceRate > 0 ? 'blue' : 'red'">{{ model.differenceRate >= 0 ? '↑' : '↓' }}{{ Math.abs(model.differenceRate || 0) | accMul }}%</span>
        <span v-if="normType == 2 || normType == 4" :class="model.differenceRate < 0 ? 'blue' : 'red'">{{ model.differenceRate >= 0 ? '↑' : '↓' }}{{ Math.abs(model.differenceRate || 0) | accMul }}%</span>
    </div>
  </div>
</template>
<script>
  export default {
    props: {
      title: {
        type: String,
        default: '',
      },
      imgPath: {
        type: String,
        default: '',
      },
      model: {
        type: Object,
        default: () => {
          return {
          };
        },
      },
      isTop: {
        type: Boolean,
        default: false,
      },
      isAll: {
        type: Boolean,
        default: false,
      },
      // 13收入 24支出
      normType: {
        type: Number,
        default: 1,
      },
    },

    data() {
      return {};
    },

    methods: {
      goDictionary(name) {
        let url = '/businessAssets/dataDic/index?token=1BECA34141E04A338B570F70C780C955&menuId=caa9147d6ba64e1a95bd3eeb76cc5203&parentMenuId=7ee2400d0e72437aa3bdb5823497537f&timestamp=1667202507216&keyWord=' + name;
        window.open(url);
      },
    },
  };
</script>

<style lang="scss" scoped>
  .grid-item-box {
    width: 100%;
    border-radius: 5px;
    padding: 15px 0;
    .title {
      text-align: center;
    }
    .total-price {
      color: #333333;
      font-size: 26px;
      text-align: center;
      font-weight: bold;
      padding: 15px 0;
    }
    .plan-item {
      text-align: center;
      font-size: 12px;
      color: #666;
    
      .blue {
        color: #29c37f;
      }
      .red {
        color: #eb5757;
      }
    }
  }
  .bg-box {
    background: #f8f8f8;
  }
  .difference-box{
    display: inline-block;
    width: 56px;
    text-align: right;
    margin-left: 20px;
  }
  .plan-box-l{
    display: inline-block;
    width: 130px;
    text-align: right;
  }
  .plan-box-m{
    display: inline-block;
    width: 87px;
    text-align: right;
  }
  img {
    width: 16px;
    height: 16px;
  }
</style>
